using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
	public class points_of_interest : MangosBase
	{
		public System.UInt32? entry;
		public System.Single? x;
		public System.Single? y;
		public System.UInt32? icon;
		public System.UInt32? flags;
		public System.UInt32? data;
		public System.String icon_name;




		public override string GetInsertCommand()
		{
			return string.Format("INSERT IGNORE INTO `points_of_interest` (`entry`, `x`, `y`, `icon`, `flags`, `data`, `icon_name`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}');", entry.GetValueOrDefault(), x.GetValueOrDefault(), y.GetValueOrDefault(), icon.GetValueOrDefault(), flags.GetValueOrDefault(), data.GetValueOrDefault(), icon_name.MySQLDBString());
		}


		public override string GetUpdateCommand()
		{
            StringBuilder sb = new StringBuilder();
						sb.Append("UPDATE `points_of_interest` SET ");
			if(x != null)
			{
				sb.AppendLine("`x`='" + x.Value.ToString() + "'");
			}
			if(y != null)
			{
				sb.AppendLine("`y`='" + y.Value.ToString() + "'");
			}
			if(icon != null)
			{
				sb.AppendLine("`icon`='" + icon.Value.ToString() + "'");
			}
			if(flags != null)
			{
				sb.AppendLine("`flags`='" + flags.Value.ToString() + "'");
			}
			if(data != null)
			{
				sb.AppendLine("`data`='" + data.Value.ToString() + "'");
			}
			if(icon_name != null)
			{
				sb.AppendLine("`icon_name`='" + icon_name.MySQLDBString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `entry`='" + entry.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}


	}
}
